PopupManager = {
	getComplaintPopup: function(params, callback){
		var bigClientStore = StoreManager.getComplaintStore();//大客户
		var columns = [new Ext.grid.RowNumberer({
			width: 30
		}), {
			header: "投诉工单号",
			dataIndex: "imepId",
			width: 90,
			sortable: true
		}, {
			header: "工单流水号",
			dataIndex: "woId",
			width: 140,
			sortable: true
		}, {
			header: "受理时间",
			dataIndex: "dealTime",
			width: 65,
			sortable: true
		}, {
			header: "用户姓名",
			dataIndex: "customerName",
			width: 70,
			sortable: true
		}, {
			header: "用户手机号",
			dataIndex: "customerMobile",
			width: 70,
			sortable: true
		}, {
			header: "用户投诉内容",
			dataIndex: "complaintContent",
			width: 70,
			sortable: true
		}, {
			header: "投诉地址",
			dataIndex: "address",
			width: 70,
			sortable: true
		}, {
			header: "造成投诉原因",
			dataIndex: "reason",
			width: 170,
			sortable: true
		}, {
			header: "经度",
			dataIndex: "longitude",
			width: 170,
			sortable: true
		}, {
			header: "纬度",
			dataIndex: "latitude",
			width: 170,
			sortable: true
		}, {
			header: "是否解决",
			dataIndex: "resolve",
			width: 170,
			sortable: true
		}];
		
		
		var searchPanel = new Ext.form.FormPanel({
			frame: true,
			layout: "table",
			defaults:{
				border:false,
				layout:'form',
        		labelAlign:'left',
        		labelWidth:100
			},
			layoutConfig: {
				columns: 6
			},
			bodyStyle: "line-height: 26px",
			items: [{
				colspan:2,
				items:{
					width:100,
					fieldLabel:'投诉工单号',
					xtype: "textfield",
					id: "imepId",
					name: "complaintSO.imepId"
				}
			}, {
				colspan:2,
				items:{
					width:100,
					fieldLabel:'用户投诉内容',
					xtype: "textfield",
					id: "complaintContent",
					name: "complaintSO.complaintContent"
				}
			}, {
				colspan:2,
				items:{
					width:100,
					fieldLabel:'投诉地址',
					xtype: "textfield",
					id: "address",
					name: "complaintSO.address"
				}
			}],
			buttonAlign: "left",
			buttons: [{
				xtype: "button",
				text: "查询",
				scope: this,
				handler: function(){
					var params = searchPanel.getForm().getValues();
					bigClientStore.reload({
						"params": params
					});
				}
			}, {
				xtype: "button",
				text: "清空查询",
				scope: this,
				handler: function(){
					searchPanel.getForm().setValues([{
						id: "imepId",
						value: ""
					}, {
						id: "complaintContent",
						value: ""
					}, {
						id: "address",
						value: ""
					}]);
					var params = searchPanel.getForm().getValues();
					bigClientStore.reload({
						"params": params
					});
				}
			}],
			keys: [{
				key: 13,
				fn: function(){
					var formParams = searchPanel.getForm().getValues();
					bigClientStore.reload({
						"params": formParams
					});
				}
			}]
		});
		/*
		var bigClientPanel = new Ext.grid.GridPanel({
			title: "大客户投诉",
			width: 640,
			height: 399,
			stripeRows: true,
			loadMask: true,
			store: bigClientStore,
			columns: columns,
			listeners: {
				rowdblclick: function(){
					var record = bigClientPanel.getSelectionModel().getSelected();
					popup.actionHandler(record);
				}
			}
		});*/
		
		var bigClientGridPanel = new Ext.grid.GridPanel({
			width: 640,
			height: 274,
			stripeRows: true,
			loadMask: true,
			store: bigClientStore,
			columns: columns,
			sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
			bbar: new Ext.PagingToolbar({
				pageSize: 15,
				store: bigClientStore,
				displayInfo: true
			}),
			listeners: {
				rowdblclick: function(){
					var record = bigClientGridPanel.getSelectionModel().getSelected();
					popup.dbClickActionHandler(record);
				}
			}
		});
		var bigClientPanel = new Ext.Panel({
			title: "请选择关联投诉信息",
			width: 640,
			autoHeight: true,
			items: [searchPanel,bigClientGridPanel],
			
			getSelectionModel: function(){
				return bigClientGridPanel.getSelectionModel();
			},
			listeners: {
				activate: function(p){
				    /*
					if (!bigClientStore.loaded) {
						var formParams = searchPanel.getForm().getValues();
						bigClientStore.reload({
							"params": formParams
						});
						bigClientStore.loaded = true;
					}
					*/
				}
			}
			
		});
		
		
		var tabPanel = new Ext.TabPanel({
			activeItem: 0,
			items: [bigClientPanel]
		});
		var popup = new Ext.Window({
			width: 656,
			autoHeight: true,
			// height: 448,
			frame: true,
			modal: true,
			closable: true,
			items: tabPanel,
			buttons: [{
				xtype: "button",
				text: "选择",
				scope: this,
				handler: function(){
					var record = tabPanel.getActiveTab().getSelectionModel().getSelected();
					if (!record) {
						Ext.Msg.alert("提示", "请选择表中的数据");
						return;
					}
					popup.actionHandler(record);
				}
			}, {
				xtype: "button",
				text: "取消",
				scope: this,
				handler: function(){
					popup.close();
				}
			}, {
				xtype: "spacer",
				width: "360"
			}
			/*
			, {
				xtype: "button",
				text: "清空",
				scope: this,
				handler: function(){
					var record = {
						data: ""
					};
					popup.actionHandler(record);
				}
			}*/
			
			]
		});
		popup.actionHandler = function(record){
			this.close();
			callback(record.data);
		};
		popup.dbClickActionHandler = function(record){
			callback(record.data);
		};
		popup.show();
		bigClientStore.baseParams = params;
		bigClientStore.reload();
		return popup;
	}
	
}





